﻿#include "CDevDataBeltRealign.h"
#include "CGlobal.h"

CDevDataBeltRealign::CDevDataBeltRealign()
{
	resetData();
}

CDevDataBeltRealign::~CDevDataBeltRealign()
{
	/*for (auto itor = m_mapDevPoint.begin(); itor != m_mapDevPoint.end(); itor++)
	{
		CDevPoint* pPoint = itor.value();
		delete pPoint;
		pPoint = nullptr;
	}
	m_mapDevPoint.clear();*/
	if (m_pMutex)
	{
		delete m_pMutex;
		m_pMutex = nullptr;
	}
	if (m_pDevDataCam)
	{
		delete m_pDevDataCam;
		m_pDevDataCam = nullptr;
	}
}

void CDevDataBeltRealign::resetData()
{
	m_pMutex = new QMutex();
	m_sPointGuid = "";                              //纠偏点GUID
	m_sPointName = A2T("跑偏检测点");                //纠偏点名称
	m_sPlcIpAddress = "127.0.0.1";                  //纠偏点PLC地址
	m_nPlcPort = 502;                               //纠偏点PLC端口号
	m_dRightRaito = 1;								//左偏值比率
	m_dLeftRaito = 1;								//右偏值比率
	m_dLeftCurrVal = 0.0;						    //左侧实时偏离值
	m_dRightCurrVal = 0.0;					        //右侧实时偏离值
	m_mapAddrDataR;								    //读 测点序号 测点地址结构体
	m_mapAddrDataW;									//写 测点序号 测点地址结构体
	m_sBeltName = "";						        //皮带名称
	m_qModifyTime = QDateTime::currentDateTime();	//最后修改时间
	m_sModifyPerson = "";							//修改人
	m_nIsHaveDev = 0;
	m_nIsHaveBeltRunState = 0;						//是否有皮带启停信号
	m_nBeltStateType = 0;
	m_pDevDataCam = new CDevDataCam();

	m_nCamerState = 0;
	m_nAlgNum = 0;
	m_nAlgState = 0;
	m_nAlgTime = 120;
	m_nRealignSetValue = 0;
	m_nRealignSetValueTwo = 0;
	m_bIsCorrect = false;
	m_bIsCorrectTwo = false;
	m_vecLeftValue.clear();
	m_vecRightValue.clear();

	//跑偏结果相关
	m_bIsRecord = false;
	m_sResultGuid = "";
	m_sRecordPath = "D:/RobotResult/";
	m_sBeltStateGuid = "";
	m_bBeltWork = false;
	m_nLogNum = 0;
	m_nResultNum = 600;
	m_nDisAlarmNum = 0;

	//PLC相关数据
	m_bPlcConnectState = false;
	m_bPlcConnectStateValue = true;
	m_nRecRemoteAuto = 0;
	m_nRecRemoteHand = 0;
	m_nRecOffsetValue = 0;
	m_nRealignSetValueTwo = 0;
	m_nRecCamerLeft = 0;
	m_nRecCamerRight = 0;
	m_nRecErrorAlarm = 0;
	m_nRecRemoteCtlFeedback = 0;
	m_nRecLocalLeftRun = 0;
	m_nRecLocalRightRun = 0;
	m_nRecMotorRunFeedback = 0;
	m_nRecLeftYVRunFeedback = 0;
	m_nRecRightYVRunFeedback = 0;

	m_mapInputPointAddr.insert(A2T("皮带启停信号"),"");
	m_mapInputPoint.insert(A2T("皮带启停信号"), nullptr);
}
